<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="js/jquery.js"></script>
    <title>登录</title>
</head>
<body>
    <div>
        用户名：<input id="username" type="text">
        密码：<input id="password" type="text">
        <input type="button" value="登录" onclick="login()">
    </div>
</body>
<script>
    function login(){
        if (!$("#username").val() || !$("#password").val()){
            alert("请输入信息")
            return false;
        }

        $.post("/login",{
            "username": $("#username").val(),
            "password": $("#password").val(),
        },function (res) {
            if (res){
                location.href = "main.html";
            }else {
                alert("登录错误")
                return false;
            }
        });

    }
</script>
</html>